package kizzo.game 
{	
	import away3d.entities.SegmentSet;
	import away3d.events.Object3DEvent;
	import away3d.primitives.LineSegment;
	import flash.events.Event;
	import flash.geom.Vector3D;
	import kizzo.game.tile_objects.GameCube;
	import kizzo.geometry.TileCoord3D;
	import kizzo.particle_system.Particle;
	/**
	 * ...
	 * @author KiZZo
	 */
	public class Link 
	{
		public var link_child:GameCube;
		public var link_parent:GameCube;
				
		public var boost:Boolean;
		public var mirror_x:Boolean;
		public var mirror_z:Boolean;
				
		protected var modifiers:Vector.<LinkModifier>;		
		
		public function Link(link_child:GameCube, link_parent:GameCube) 
		{
			this.link_child = link_child;			
			this.link_parent = link_parent;
			
			this.modifiers = new Vector.<LinkModifier>();
			boost = false;
			mirror_x = false;
			mirror_z = false;
		}
		
		
		public function add_modifier(modifier:LinkModifier):void
		{
			this.modifiers.push(modifier);
		}
		
		
		public function get_modifier(mod_type:Class):LinkModifier
		{
			var modifier:LinkModifier = null;
			
			for (var i:uint = 0; i < this.modifiers.length; i++)
			{
				if (this.modifiers[i] is mod_type)
				modifier = this.modifiers[i];
			}
			
			return modifier;
		}
		
		
		public function clear_modifiers():void
		{
			this.modifiers = new Vector.<LinkModifier>();			
			boost = false;
			mirror_x = false;
			mirror_z = false;
			
		}
		
		
		public function modify(v:TileCoord3D):TileCoord3D
		{
			for (var i:uint = 0; i < this.modifiers.length; i++)
			{
				v = modifiers[i].apply(v);				
			}
			return v;
		}

	}

}